//
//  EditorViewController.m
//  mhome
//
//  Created by YaSha_Tom on 2018/12/10.
//  Copyright © 2018年 刘春雷. All rights reserved.
//

#import "EditorViewController.h"

@interface EditorViewController ()
@property (nonatomic,strong)NSMutableArray *preferences;
@property (nonatomic,strong)NSMutableArray *preferencesCode;

@end

@implementation EditorViewController
- (NSMutableArray *)preferences{
    if (!_preferences) {
        _preferences = [NSMutableArray array];
    }
    return _preferences;
}
- (NSMutableArray *)preferencesCode{
    if (!_preferencesCode) {
        _preferencesCode = [NSMutableArray array];
    }
    return _preferencesCode;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title  = @"编辑个人信息";
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton *btns1 = [[UIButton alloc]initWithFrame:CGRects(0, 30, 59, 14)];
    //右边按钮
    [btns1 addTarget:self action:@selector(backs) forControlEvents:UIControlEventTouchUpInside];
    [btns1 setTitle:@"保存" forState:UIControlStateNormal];
    btns1.titleLabel.font=[UIFont systemFontOfSize:14.0*BIZ];
    [btns1 setTitleColor:[UIColor colorWithRed:123.0/255.0 green:131.0/255.0 blue:141.0/255.0 alpha:1.0] forState:UIControlStateNormal];
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:btns1];
    self.navigationItem.rightBarButtonItem = item1;

}

- (void)styleRequest {
    NSString *urlString = [NSString stringWithFormat:@"%@appserve/common/getBaseDataByType",Domain];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSUserDefaults *de = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = @{@"typeCode":@"1400",@"appkey":[de stringForKey:@"appkey"],@"userId":[de stringForKey:@"userid"]};
    [manager POST:urlString parameters:dic progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        if ([[NSString stringWithFormat:@"%@",dic[@"code"]] isEqualToString:@"1"]) {
            NSArray *ar = dic[@"data"];
            for (int i = 0; i < ar.count; i++) {
                NSDictionary *dic1 = ar[i];
                [self.preferences addObject:dic1[@"name"]];
                [self.preferencesCode addObject:dic1[@"code"]];
            }
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error = %@",error);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
